#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 2e5 + 10;
const int MOD = 1e9 + 7;

int t, n;
string s[2];

int dp[2][MAXN];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> t;
    while (t--) {
        cin >> n >> s[0] >> s[1];
        for (int i = 0; i <= n; i++) dp[0][i] = dp[1][i] = 0;

        int l = 0, r = n - 1;
        while (s[0][l] == '.' && s[1][l] == '.') l++;
        while (s[0][r] == '.' && s[1][r] == '.') r--;

        // cout << l << ',' << r << endl;

        if (s[0][l] == '*' && s[1][l] == '*') dp[0][l] = dp[1][l] = 1;
        else if (s[0][l] == '*') dp[1][l] = 1;
        else dp[0][l] = 1;

        // cout << dp[0][l] << ',' << dp[1][l] << endl;
        for (int i = l + 1; i <= r; i++) {
            for (int j = 0; j <= 1; j++) {
                dp[j][i] = min(dp[j ^ 1][i - 1] + 2, dp[j][i - 1] + 1 + (s[j^1][i] == '*'));
            }
        }

        int ans = min(dp[0][r], dp[1][r]);
        cout << ans << endl;
    }
    return 0;
}